﻿/*-----------------------------------------------
// File: HeroIconTemplate.cs
// Description: 
// Author: Shaobing	492057342@qq.com
-----------------------------------------------*/
using UnityEngine;
using System.Collections;

namespace UI
{
    public class HeroIconTemplate : IconTemplate 
    {
        public UISprite iconBg;
        public UISprite iconFrame;

        public virtual void SetHero(string id) {
            var dh = Dict.Blo.DictHeroBlo.GetTableHero(id);
            SetIcon(TextureIcon.HERO, dh.iconName);
            QualityValue quality = QualityValue.WHITE;
            if (dh != null) {
                quality = (QualityValue)dh.quality;
            }
            SetIconBGAndFrameByQuality(quality);
        }

        public virtual void SetIconBGAndFrameByQuality(QualityValue quality) {
            switch (quality)
            {
                case QualityValue.WHITE:
                    {
                        iconBg.spriteName = "UI_kuang_big_di_white";
                        iconFrame.spriteName = "UI_kuang_big_bian_white";
                    }
                    break;
                case QualityValue.GREEN:
                    {
                        iconBg.spriteName = "UI_kuang_big_di_green";
                        iconFrame.spriteName = "UI_kuang_big_bian_green";
                    }
                    break;
                case QualityValue.BLUE:
                    {
                        iconBg.spriteName = "UI_kuang_big_di_blue";
                        iconFrame.spriteName = "UI_kuang_big_bian_blue";
                    }
                    break;
                case QualityValue.PURPLE:
                    {
                        iconBg.spriteName = "UI_kuang_big_di_zi";
                        iconFrame.spriteName = "UI_kuang_big_bian_zi";
                    }
                    break;
                case QualityValue.YELLOW:
                    {
                        iconBg.spriteName = "UI_kuang_big_di_yellow";
                        iconFrame.spriteName = "UI_kuang_big_bian_yellow";
                    }
                    break;
                case QualityValue.RED:
                    {
                        iconBg.spriteName = "UI_kuang_big_di_red";
                        iconFrame.spriteName = "UI_kuang_big_bian_red";
                    }
                    break;
                default:
                    {
                        iconBg.spriteName = "UI_kuang_big_di_white";
                        iconFrame.spriteName = "UI_kuang_big_bian_white";
                    }
                    break;
            }
        }
    }
}